<?php
namespace app\agent\logic;

use app\common\model\StatisticsWljfModel;

class StatisticsWljfLogic extends StatisticsWljfModel
{
	
	public function getPage($where = [], $request = [])
	{
		//排序
		$order = [
				'status' => 'DESC',
				$this->getPk() => 'DESC',
		];

		//查询数据
		$data = $this->where($where)->order($order)->paginate(10, false, ['query' => $request]);

		//字段属性映射
		foreach ($data as $key => &$val)
		{
			$this->attributeMap($val);
		}
		
		return $data;
	}

	public function updateRecord($data = [])
	{
		//入库
		$data = $this->allowField(true)->save($data, [$this->getPk() => $data['id']]);
		
		if( $data === false )
		{
			return false;
		}
		
		return true;
	}
	
	public function destroyRecord($id = 0)
	{
		return $this->delete($id);
	}

	public function getDetail($where = [])
	{
		//查询数据
		$data = $this->where($where)->find();

		//字段属性映射
		$data = $this->attributeMap($data);

		return $data;
	}
}